package com.czl.module_storehouse.mvp.presenter;

import com.czl.base.data.bean.tengyun.LocatListBean;
import com.czl.base.data.bean.tengyun.SortBean;
import com.czl.base.data.bean.tengyun.StorehouseBean;
import com.czl.module_base.bean.ListBean;
import com.czl.module_base.http.HttpResponse;
import com.czl.module_base.mvp.presenter.BasePresenter;
import com.czl.module_base.mvp.view.SimpleView;
import com.czl.module_base.observer.AbsHandleSubscriber;
import com.czl.module_storehouse.mvp.model.StockModel;

/**
 * @author by xubin
 * PS: Not easy to write code, please indicate.
 */
public class StockPresenter extends BasePresenter<StockModel, SimpleView> {

    public void getStorehouseLocatStockInfo(String roomId) {
        doSubscribe(mModel.getStorehouseLocatStockInfo(roomId), new AbsHandleSubscriber<HttpResponse<ListBean<LocatListBean>>>() {
            @Override
            public void onSuccess(HttpResponse<ListBean<LocatListBean>> httpResponse) {
                mView.showData(httpResponse.getData());
            }
        }, false);
    }

    public void getStorehouseSortStockInfo(Integer sortId, String sortCode) {
        doSubscribe(mModel.getStorehouseSortStockInfo(sortId, sortCode), new AbsHandleSubscriber<HttpResponse<SortBean>>(mView) {
            @Override
            public void onSuccess(HttpResponse<SortBean> httpResponse) {
                mView.showHttpResponse(httpResponse);
            }
        });
    }

    public void getStorehouseStockInfo(boolean refresh, String name) {
        resetPageNo(refresh);
        doSubscribe(mModel.getStorehouseStockInfo(mPageNo, name), new AbsHandleSubscriber<HttpResponse<ListBean<SortBean>>>(mView) {
            @Override
            public void onSuccess(HttpResponse<ListBean<SortBean>> httpResponse) {
                mView.showData(httpResponse.getData());
                nextPageNo();
            }
        });
    }

    public void getStorehouseStockWarnList(String storehouseId) {
        doSubscribe(mModel.getStorehouseStockWarnList(storehouseId), new AbsHandleSubscriber<HttpResponse<ListBean<StorehouseBean.StockWarnBean>>>(mView) {
            @Override
            public void onSuccess(HttpResponse<ListBean<StorehouseBean.StockWarnBean>> httpResponse) {
                mView.showData(httpResponse.getData());
            }
        });
    }
}
